package com.news.model;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 新闻条目数据模型
 */
public class NewsItem {
    private String title;           // 标题
    private String content;         // 内容摘要
    private String source;          // 来源网站
    private String url;             // 原文链接
    private LocalDateTime publishTime; // 发布时间
    private String category;        // 分类
    private String imageUrl;        // 图片链接
    private int hotScore;           // 热度评分
    private String author;          // 作者

    public NewsItem() {
    }

    public NewsItem(String title, String content, String source, String url, LocalDateTime publishTime) {
        this.title = title;
        this.content = content;
        this.source = source;
        this.url = url;
        this.publishTime = publishTime;
    }

    // Getters and Setters
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public LocalDateTime getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(LocalDateTime publishTime) {
        this.publishTime = publishTime;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public int getHotScore() {
        return hotScore;
    }

    public void setHotScore(int hotScore) {
        this.hotScore = hotScore;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NewsItem newsItem = (NewsItem) o;
        return Objects.equals(title, newsItem.title) &&
               Objects.equals(url, newsItem.url) &&
               Objects.equals(source, newsItem.source);
    }

    @Override
    public int hashCode() {
        return Objects.hash(title, url, source);
    }

    @Override
    public String toString() {
        return "NewsItem{" +
                "title='" + title + '\'' +
                ", source='" + source + '\'' +
                ", publishTime=" + publishTime +
                ", hotScore=" + hotScore +
                '}';
    }
} 